package com.woniuxy.yogaapp.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.yogaapp.pojo.Pocket;

public interface PocketMapper {
	/**
	 * 根据用户id 查询该用户的钱包
	 * 
	 * @param pocket
	 * @return
	 */
	@Select("select * from pocket where puid=#{puid}")
	Pocket findPocketByPuid(Pocket pocket);
	/**
	 * 添加该用户钱包    puid  pass
	 * @param pocket
	 * @return
	 */
	@Insert("insert into pocket(puid,pass) values (#{puid},#{pass})")
	int addPocket(Pocket pocket);
	
	/**
	 * 充值  或者支付
	 */
	@Update("update pocket set money=#{money} where puid=#{puid}")
	int rechargeMoney(Pocket pocket);
	
	/**
	 * 绑定银行卡   需要puid  和银行卡号
	 * @param pocket
	 * @return
	 */
	@Update("update pocket set bankcard=#{bankcard}  where puid=#{puid}")
	int bindingBankCard(Pocket pocket);
	
	/**
	 * 取现  余额减少   银行卡余额加
	 * @param po
	 * @return
	 */
	@Update("update pocket set money=#{money},cardmoney=#{cardmoney} where puid=#{puid}")
	int withdrawal(Pocket po);

	/**
	 * 更改商户编号
	 * @param pocket
	 */
	@Update("update pocket set ordernumber=#{ordernumber} where puid=#{puid}")
	void updateOrdernumber(Pocket pocket);
	
	
	/**
	 * 查询 ordernumber
	 */
	@Select("select puid from pocket where ordernumber=#{ordernumber}")
	int findPuidByOrdernumber(String ordernumber);
}
